<template>
	<view>
		<uni-search-bar :radius="100" @input="search" @cancel="cancel" placeholder="输入教师名字"></uni-search-bar>
		<view class="list">
			<view class="item" v-for="item in personList" :key="item.tid" @click="go(item.id)">{{item.name}}</view>
		</view>
		<view v-if="nothing" class="nothing">没有结果</view>
	</view>
</template>

<script>
	import {
		findPerson
	} from '@/api/search.js'
	import uniSearchBar from '@/components/uni-search-bar/uni-search-bar.vue'

	export default {
		components: {
			uniSearchBar
		},
		data() {
			return {
				personList: [],
				nothing: false
			}
		},
		methods: {
			search(e) {
				findPerson({
					name: e.value
				}).then(res => {
					this.personList = res.data.data
					this.nothing =	res.data.data.length == 0
				})

			},
			go(tid) {
				uni.navigateTo({
					url: '../tutor/baseInfo/homePage?tid=' + tid
				})
			},
			cancel(e){
				this.personList = []
				this.nothing = false
			}
		}
	}
</script>

<style>
	.list {
		margin: 0 10px;
		border: 1px solid #b2b1b5;
		border-top: none;
		border-bottom-left-radius: 10px;
		border-bottom-right-radius: 10px;
	}

	.item {
		font-size: 16px;
		border-bottom: 1px solid #c8c7cc;
		color: #908090;
		padding-left: 5px;
		margin: 10px;
	}

	.nothing {
		background-color: #f7f7f7;
		margin: 0 10px;
		font-size: 16px;
		text-align: center;
		color: #808080;
		height: 30px;
		line-height: 30px;
	}
</style>
